<?php

/**
 * This is the model class for table "motility".
 *
 * The followings are the available columns in table 'motility':
 * @property integer $id
 * @property string $eoms
 * @property string $eye_dominance
 * @property string $other
 * @property string $near_point_accomodation
 * @property string $amplitude_of_accomodation
 * @property string $near_point_coverage
 * @property integer $rx_id
 * @property integer $personalinfo_id
 *
 * The followings are the available model relations:
 * @property Rx $rx
 * @property PersonalInformation $personalinfo
 */
class Motility extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Motility the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'motility';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('rx_id, personalinfo_id', 'numerical', 'integerOnly'=>true),
			array('eoms, other', 'length', 'max'=>20),
			array('eye_dominance', 'length', 'max'=>10),
			array('near_point_accomodation, amplitude_of_accomodation, near_point_coverage', 'length', 'max'=>5),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, eoms, eye_dominance, other, near_point_accomodation, amplitude_of_accomodation, near_point_coverage, rx_id, personalinfo_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'rx' => array(self::BELONGS_TO, 'Rx', 'rx_id'),
			'personalinfo' => array(self::BELONGS_TO, 'PersonalInformation', 'personalinfo_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'eoms' => 'Eoms',
			'eye_dominance' => 'Eye Dominance',
			'other' => 'Other',
			'near_point_accomodation' => 'Near Point Accomodation',
			'amplitude_of_accomodation' => 'Amplitude Of Accomodation',
			'near_point_coverage' => 'Near Point Coverage',
			'rx_id' => 'Rx',
			'personalinfo_id' => 'Personalinfo',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('eoms',$this->eoms,true);
		$criteria->compare('eye_dominance',$this->eye_dominance,true);
		$criteria->compare('other',$this->other,true);
		$criteria->compare('near_point_accomodation',$this->near_point_accomodation,true);
		$criteria->compare('amplitude_of_accomodation',$this->amplitude_of_accomodation,true);
		$criteria->compare('near_point_coverage',$this->near_point_coverage,true);
		$criteria->compare('rx_id',$this->rx_id);
		$criteria->compare('personalinfo_id',$this->personalinfo_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}